package com.topscore.uke.mvp.contractors;

import com.topscore.uke.entities.UserSalesInfo;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class GetUserSaleInfoModel implements GetUserSalesContractor.Model {
    private CallBack mCallBack;

    public GetUserSaleInfoModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void getData(String loginName) {
        mService.getUserSales(loginName)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<UserSalesInfo>>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse<UserSalesInfo> response) {
                        mCallBack.onSuccess(response);
                    }
                });
    }
}
